'use strict';

const Controller = require('egg').Controller;

class Xyt_wuzicontrollerController extends Controller {
    // 返回所有表
    async listAll() {
        // 调用service 的方法
        const result = await this.service.xytWuzi.listAll();
        this.ctx.body = {
          statuscode: 200,
          vmessage: 'ok',
          result,
        };
      }
  // post请求方式 新增一个物资来源
  async addNewWuzi() {
    // 调用service 的方法
    const biz_supplier = this.ctx.request.body;
    const result = await this.service.xytWuzi.addNewWuzi(biz_supplier);
    this.ctx.body = {
      statuscode: 200,
      vmessage: '新增OK',
      affectrow: result.affectedRows,
    };
  }
  // 根据id删除 物资来源
  async delwuzi() {
    // 调用service 的方法
    const biz_supplier = this.ctx.request.body;
    const result = await this.service.xytWuzi.delwuzi(biz_supplier);
    this.ctx.body = {
      statuscode: 200,
      vmessage: '删除OK',
      result,
    };
  }
  //根据id 获取物资来源
  async updatehuoqu(){
    const biz_supplier = this.ctx.request.body;
    const result = await this.service.xytWuzi.updatehuoqu(biz_supplier);
    this.ctx.body = {
      statuscode: 200,
      msg: '获取成功',
      result
    }
  }
  //更新物资来源
  async updatewuzi() {
    // 调用service 的方法
    const biz_supplier = this.ctx.request.body;
    const result = await this.service.xytWuzi.updatewuzi(biz_supplier);
    this.ctx.body = {
      statuscode: 200,
      vmessage: '修改OK',
      affectrow: result.affectedRows,
    };
  }

  async listwuzi() {
    let paramsObject = this.ctx.request.body;
    let result = await this.service.xytWuzi.listwuzi(paramsObject);
    this.ctx.body = {
        code: 200,
        message: '按条件查询用户成功',
        result
    }
}
}

module.exports = Xyt_wuzicontrollerController;
